<template>
  <div>
    <view-box>
      <x-header slot="header">投票成功</x-header>
      <msg :title="title" :description="description" :buttons="buttons" :icon="icon"></msg>
    </view-box>
  </div>
</template>

<script>
import { XHeader, ViewBox, Msg, Divider, XButton } from "vux";
import { mapState } from "vuex";

export default {
  name: "Success",
  // props: ["voteId"],
  components: {
    XHeader,
    ViewBox,
    Msg,
    Divider,
    XButton
  },
  computed: {
    ...mapState({
      // 映射 this.count 为 store.state.msg.count
      voteId: state => state.vote.currentVote.id
    })
  },
  methods: {},
  data() {
    return {
      title: "投票成功",
      description:
        "恭喜您！完成本次投票，你可以根据下方提示操作，立即查看本次投票结果或者返回到首页。",
      icon: "success",
      buttons: [
        {
          type: "primary",
          text: "查看结果",
          onClick: () =>
            this.$router.replace({
              name: "Result",
              params: { voteId: this.voteId }
            })
        },
        {
          type: "default",
          text: "回到首页",
          link: "/"
        }
      ]
    };
  }
};
</script>
